import request from '@/utils/request'

export default {
    // 获取广告信息
    getList(query, current = 1, size = 20) {
        return request({
            url: '/article/advert/search',
            method: 'post',
            data: {
                ...query,
                current,
                size
            }

        })
    },
    // 上传图片
    uploadImg(data) {
        return request({
            url: '/article/file/upload',
            method: 'post',
            data
        })
    },
    // 删除图片
    deleteImg(imageUrl) {
        return request({
            url: '/article/file/delete',
            method: 'delete',
            params: { 'fileUrl': imageUrl }
        })
    },

    // 增加新广告
    add(data) {
        return request({
            url: '/article/advert',
            method: 'post',
            data: data

        })
    },
    // 通过id查询
    getById(id) {
        return request({
            url: `/article/advert/${id}`,
            method: 'get',
        })
    },
    // 更新数据
    update(data) {
        return request({
            url: `/article/advert`,
            method: 'put',
            data: data
        })
    },
    // 根据ID删除
    deleteById(id) {
        return request({
            url: `/article/advert/${id}`,
            method: 'delete',

        })
    }
}